# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=postgresql-pgvector
_projname=pgvector
pkgver=0.6.2
pkgrel=1
pkgdesc="Open-source vector similarity search for PostgreSQL"
url="https://github.com/pgvector/pgvector"
arch="all"
license="PostgreSQL"
makedepends="postgresql-dev"
subpackages="$pkgname-dev $pkgname-bitcode"
source="https://github.com/pgvector/pgvector/archive/v$pkgver/$_projname-$pkgver.tar.gz"
builddir="$srcdir/$_projname-$pkgver"
options="!check"  # tests require running PostgreSQL

build() {
	# OPTFLAGS: avoid building with -march=native.
	make OPTFLAGS=""
}

package() {
	depends="postgresql$(pg_config --major-version)"

	make DESTDIR="$pkgdir" install
}

bitcode() {
	pkgdesc="$pkgdesc (bitcode for JIT)"
	depends="$pkgname=$pkgver-r$pkgrel"
	install_if="postgresql$(pg_config --major-version)-jit $pkgname=$pkgver-r$pkgrel"

	amove usr/lib/postgresql*/bitcode
}

sha512sums="
745ec77d6540a01a867e0b44964c583ff17b78749ea2b2c8555d7f5605d4f0956d68b921e99a03317e1c30fb4ba5f1b4426a8a06fa7e28f1b6ae365d8a41a661  pgvector-0.6.2.tar.gz
"
